package com.base.io;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * IO流，读取properties属性文件
 *
 * @author innocent
 * @date 2019/2/21 17:15
 */
public class IODemo {
    public static void main(String[] args) {
        //如果不通过类加载器，就会报空指针异常
        InputStream resourceAsStream = IODemo.class.getClassLoader().getResourceAsStream("test.properties");
        Properties prop = new Properties();
        System.out.println("prop = " + prop);
        try {
            prop.load(resourceAsStream);
        } catch (IOException e) {
            System.out.println("加载异常");
            e.printStackTrace();
        }
        String username = prop.getProperty("username");
        System.out.println("username = " + username);
    }

    public void test() {
        System.out.println("hello"+'a'+1);
        System.out.println('a'+1+"hello");
        System.out.println("5+5="+5+5);
        System.out.println(5+5+"=5+5");

        byte b = (byte)130;
        System.out.println("b = " + b);

    }
}
